import { Scene } from 'phaser'

export class MenuScene extends Scene {
  constructor() {
    super({ key: 'MenuScene' })
  }

  preload() {
    // 加载菜单资源
    this.load.image('menu-bg', '/assets/images/menu-bg.png')
    this.load.image('menu-button', '/assets/images/menu-button.png')
    this.load.image('logo', '/assets/images/logo.png')
  }

  create() {
    // 创建菜单背景
    this.add.image(400, 300, 'menu-bg')

    // 创建游戏标题
    this.add
      .text(400, 150, '肉鸽地牢冒险', {
        fontSize: '48px',
        color: '#ffffff',
        fontFamily: 'Arial',
      })
      .setOrigin(0.5)

    // 创建开始游戏按钮
    const startButton = this.add.image(400, 300, 'menu-button')
    startButton.setInteractive()

    this.add
      .text(400, 300, '开始游戏', {
        fontSize: '24px',
        color: '#000000',
        fontFamily: 'Arial',
      })
      .setOrigin(0.5)

    startButton.on('pointerdown', () => {
      this.scene.start('GameScene')
    })

    // 创建设置按钮
    const settingsButton = this.add.image(400, 380, 'menu-button')
    settingsButton.setInteractive()

    this.add
      .text(400, 380, '设置', {
        fontSize: '24px',
        color: '#000000',
        fontFamily: 'Arial',
      })
      .setOrigin(0.5)

    settingsButton.on('pointerdown', () => {
      this.scene.start('SettingsScene')
    })
  }
}
